package com.archerdu.apply.dao.hibernate;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Example;
import org.hibernate.criterion.Restrictions;

import com.archerdu.apply.dao.OptionDAO;
import com.archerdu.apply.model.Option;
import com.archerdu.base.dao.HibernateBaseDao;

public class OptionDAOImpl extends HibernateBaseDao<Option, Integer> implements
        OptionDAO {

    private static final long serialVersionUID = 4525546291232047831L;

	@Override
	public List<Option> findWithQuestion( Option option ) {
		DetachedCriteria criteria = this.getCriteria();
		criteria.add( Example.create( option ) );
		criteria.add(Restrictions.eq( QUESTION_ID, option.getQuestion().getId() ));
		return findByCretira( criteria );
	}
}
